#ifndef REMOTESERVER_H
#define REMOTESERVER_H

#include <QObject>
#include <QTcpServer>
#include "tcp/remotehost.h"

class ScreenCapture;

class RemoteServer : public QTcpServer
{
    Q_OBJECT
public:
    explicit RemoteServer(QObject *parent = nullptr);
    void pushWindow(ScreenCapture *window);
    void removeWindow(ScreenCapture *window);
    bool sendWindowFramebuffer(int wid, const QByteArray &data);
    bool sendCutText(const QString &text);
    bool sendCreateWindow(int wid, int width, int height, int codec);

protected:
    void incomingConnection(qintptr socketDescriptor) override;
    void on_host_disconnected();
    void on_receivedVersion(const QByteArray &version);
signals:
    void startCap();
    void pauseCap();
    void stopCap();
    void receivedKey(int wid, int key, bool isPress);
    void receivedMouse(int wid, int key, bool isPress, int x, int y);
    void receivedWheel(int wid, int delta);
    void receivedCutText(const QString& text);

public slots:
private:
    QList<RemoteHost*> VerifiList;
    QList<RemoteHost*> hostList;
    QList<ScreenCapture*> windowList;
};

#endif // REMOTESERVER_H
